package com.test.base;

import java.io.Serializable;
import java.time.LocalDateTime;

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.LocalDateTimeTypeHandler;
import org.springframework.format.annotation.DateTimeFormat;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.Data;


@Data
public class BaseEntity implements Serializable {
    /**
     * serialVersionUID.
     **/
    private static final long serialVersionUID = -7207467261346342143L;

    /**
     * 主键序列ID.
     **/
    @TableId(type = IdType.ASSIGN_UUID)
    private String id;

    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    private Boolean deleted;

    @Version
    @TableField(fill = FieldFill.INSERT)
    private Integer version;

    /**
     * 创建时间.
     **/
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.OTHER, typeHandler= LocalDateTimeTypeHandler.class)
    private LocalDateTime createTime;

    /**
     * 修改时间.
     **/
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE, jdbcType = JdbcType.OTHER, typeHandler= LocalDateTimeTypeHandler.class)
    private LocalDateTime modifyTime;
}
